package com.cn.study0011.Test0012;

import java.util.Scanner;

/**
 * @author lw
 * @ClassName Testshop.java
 * @Description
 * @createTime 2023年05月17日 07:27:00
 */
public class Testshop {
    public static void main(String[] args) {
        Shopp s=new Shopp();
        Scanner sc= new Scanner(System.in);
        double pc=0;
        s.name="华为p60";
        s.setPrice(4000);
        int count=0;
        for (int i = 1; i <=4 ; i++) {

            System.out.print("请输入"+s.getName()+"的价格：");
            pc=sc.nextDouble();
            if (pc==s.price){
                System.out.println("恭喜！您猜对了！");
                break;
            }else if (pc>s.price+1000){
                System.out.println("太大了！");
                count++;
            }else if (pc>s.price&&pc<=s.price+1000){
                System.out.println("大一些！");
                count++;
            }else if (pc<s.price-1000){
                System.out.println("太小了！");
                count++;
            }else if (pc>=s.price-1000&&pc<s.price){
                System.out.println("小一些！");
                count++;
            }
            if(count==4){
                System.out.println("4次内都没猜对，下次努力吧");
                break;
            }
            System.out.println("再猜一次：");
        }
        System.out.println("程序结束！");
    }
}
